use crate::commands::list::List;
use crate::storage::Storage;
use crate::ExecuteCommand;
use clap::Parser;

#[derive(Parser, Debug, Clone)]
pub struct Clear {
    /// 添加后展示今天的待办
    #[arg(short = 'l', long = "list")]
    pub show_list: bool,
}

impl ExecuteCommand for Clear {
    fn execute_command(&self, storage: &impl Storage) -> anyhow::Result<()> {
        storage.clear()?;

        if self.show_list {
            let list = List {
                days: None,
                status: None,
            };
            list.execute_command(storage)?;
        }

        Ok(())
    }
}